<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <h:form id="userForm" enctype="multipart/form-data">
                <br/>
                <h3 class="title">Visualizando Requerimento</h3>
                <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 
                <div class="row">
                    <div class="twelve columns"> 
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Entrada</h4></legend>
                            <p:panel id="reqPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix both">

                                <p:outputLabel value="Processo:" styleClass="grid_3"/>
                                <p:inputText styleClass="grid_8" value="#{managerSearchRequirement.showReq.process}" readonly="true" />

                                <p:outputLabel value="Tipo:" styleClass="grid_3"/>
                                <div class="grid_8">
                                    <p:selectOneMenu disabled="true" required="true" requiredMessage="O tipo de Requerimento é Obrigatório" 
                                                     value="#{managerSearchRequirement.showReq.type_requeriment}">
                                        <f:selectItem itemLabel="" itemValue=""/>
                                        <f:selectItems value="#{managerSearchRequirement.typeRequeriment}"/>  

                                    </p:selectOneMenu>
                                </div>
                                <div class="clear" /> 
                            </p:panel>

                        </fieldset>

                        <fieldset> 
                            <legend> <h4 style="margin:0 0 10px 0">Interessado</h4></legend>
                            <p:panel id="qualidadePanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix both "> 

                                <p:outputLabel value="Nome:" styleClass="grid_3"/>
                                <p:inputText styleClass="grid_20 ajustInput" value="#{managerSearchRequirement.showReq.interested}" readonly="true" />
                                <p:outputLabel value="CPF:" styleClass="grid_3"/>
                                <p:inputMask mask="999.999.999-99" styleClass="grid_8" value="#{managerSearchRequirement.showReq.cpfInterested}" readonly="true" />
                                <p:outputLabel value="Qualidade:" styleClass="grid_3"/>
                                <div class="grid_8" >
                                    <p:selectOneMenu disabled="true" required="true" requiredMessage="O tipo de Qualidade é Obrigatório" 
                                                     value="#{managerSearchRequirement.showReq.typeQuality}">
                                        <f:selectItem itemLabel="" itemValue=""/>
                                        <f:selectItems value="#{managerSearchRequirement.typeQuality}"/>  

                                    </p:selectOneMenu>
                                </div>
                                <div class="clear" /> 
                                <fieldset>  
                                    <legend> <h4 style="margin:0 0 10px 0">Endereço</h4></legend>
                                    <p:outputLabel value="Rua:" styleClass="grid_3"/>
                                    <p:inputText styleClass="grid_20 ajustInput" readonly="true"
                                                 value="#{managerSearchRequirement.showReq.addressInterested}" />
                                    
                                    <p:outputLabel value="Bairro:" styleClass="grid_3"/>
                                    <p:inputText styleClass="grid_8" readonly="true"
                                                 value="#{managerSearchRequirement.showReq.neighborhoodInterested}" />
                                    <p:outputLabel value="CEP:" styleClass="grid_2"/>
                                    <p:inputMask mask="99.999-999" styleClass="grid_4" readonly="true" 
                                                 value="#{managerSearchRequirement.showReq.zipCodeNeighborhoodInterested}" />
                                    <p:outputLabel value="Nº:" styleClass="grid_2 alpha"/>
                                    <p:inputText styleClass="grid_3" readonly="true" 
                                                 value="#{managerSearchRequirement.showReq.numInterested}" />

                                </fieldset>

                            </p:panel>

                        </fieldset>
                        
                        <fieldset>
                            <legend><h4 style="margin: 0 0 10px 0"> Proprietário </h4></legend>
                            <p:panel id="ownerPhysicalPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix" rendered="#{managerSearchRequirement.interested.typeDocument.type eq 'CPF'}">
                                
                                <p:outputLabel id="cpfOutputLabel" value="CPF:" styleClass="grid_3" />
                                <p:inputMask id="cpfOutputText" styleClass="grid_4" readonly="true"
                                             mask="999.999.999-99" value="#{managerSearchRequirement.interested.cpf}" />
                                <div class="clear" />
                                <p:outputLabel value="Nome:" styleClass="grid_3" />
                                <p:inputText styleClass="grid_20 ajustInput" readonly="true"
                                    value="#{managerSearchRequirement.interested.name}" />
                            </p:panel>
                            <p:panel id="ownerCompanyPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix" rendered="#{managerSearchRequirement.interested.typeDocument.type eq 'CNPJ'}">
                                
                                <p:outputLabel id="cnpjOutputLabel" value="CNPJ:" styleClass="grid_3" />
                                <p:inputText id="cnpjOutputText" styleClass="grid_5" readonly="true"
                                              value="#{managerSearchRequirement.interested.cnpj}" />
                                <div class="clear" />
                                
                                <p:outputLabel value="Razão Social:" styleClass="grid_3"/>
                                <p:inputText styleClass="grid_20 ajustInput" readonly="true"
                                    value="#{managerSearchRequirement.interested.name_social}" />
                            </p:panel>
                            <p:panel id="ownerAddressPanel" style="background: none; border: none; margin-top: -12px;" 
                                     styleClass="container_24 clearfix">
                                
                                <p:outputLabel id="logradouroOutputLabel" value="Logradouro:" styleClass="grid_3" />
                                <p:inputText id="logradouroOutputText" styleClass="grid_20 ajustInput"  readonly="true"
                                              value="#{managerSearchRequirement.showReq.owner.address.patio}" />
                                <div class="clear" />
                                
                                <p:outputLabel id="districtOutputLabel" value="Bairro:" styleClass="grid_3" />
                                <p:inputText id="districtOutputText" styleClass="grid_20 ajustInput" readonly="true"
                                              value="#{managerSearchRequirement.showReq.owner.address.district}" />
                                <div class="clear" />
                                
                                <p:outputLabel id="cepOutputLabel" value="CEP:" styleClass="grid_3" />
                                <p:inputMask id="cepOutputText" styleClass="grid_4" readonly="true"
                                             mask="99.999-999" value="#{managerSearchRequirement.showReq.owner.address.cep}" />
                                
                                <p:outputLabel id="numOutputLabel" value="Número:" styleClass="grid_3" />
                                <p:inputText id="numOutputText" styleClass="grid_4" readonly="true"
                                              value="#{managerSearchRequirement.showReq.owner.address.num}" />
                                
                                <p:outputLabel id="phoneOutputLabel" value="Fone:" styleClass="grid_3 alpha phoneLabel" />
                                <p:inputMask id="phoneOutputText" styleClass="grid_5" readonly="true"
                                             mask="(99) 9999-9999"
                                              value="#{managerSearchRequirement.showReq.owner.phone}" />
                            </p:panel>
                        </fieldset>

                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Situação</h4></legend>
                            <p:panel id="sitPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">            

                                <p:outputLabel value="Situação: " styleClass="grid_3"/>
                                <p:inputText styleClass="grid_20 ajustInput" readonly="true"
                                             value="#{managerSearchRequirement.showReq.status.name}" />

                            </p:panel>
                        </fieldset>

                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Imóvel</h4></legend>
                            <p:panel id="imovelPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix">

                                <p:outputLabel id="logradouroImovelOutputLabel" value="Logradouro:" styleClass="grid_3" />
                                <p:inputText id="logradouroImovelOutputText" styleClass="grid_20 ajustInput" readonly="true" 
                                             value="#{managerSearchRequirement.showReq.addressImovel}" />
                                <div class="clear" />

                                <p:outputLabel id="districtImovelOutputLabel" value="Bairro:" styleClass="grid_3" />
                                <p:inputText id="districtImovelOutputText" styleClass="grid_20 ajustInput" readonly="true"
                                             value="#{managerSearchRequirement.showReq.neighborhoodImovel}" />
                                <div class="clear" />

                                <p:outputLabel id="cepImovelOutputLabel" value="CEP:" styleClass="grid_3" />
                                <p:inputMask id="cepImovelOutputText" styleClass="grid_4" readonly="true"
                                             mask="99.999-999" value="#{managerSearchRequirement.showReq.zipCodeNeighborhood}" />

                                <p:outputLabel id="numImovelOutputLabel" value="Número:" styleClass="grid_3" />
                                <p:inputText id="numImovelOutputText" styleClass="grid_4" readonly="true"
                                             value="#{managerSearchRequirement.showReq.numberImovel}" />

                                <p:outputLabel id="phoneImovelOutputLabel" value="Fone:" styleClass="grid_3 alpha phoneLabel" />
                                <p:inputMask id="phoneImovelOutputText" styleClass="grid_5" readonly="true"
                                             mask="(99) 9999-9999" value="#{managerSearchRequirement.showReq.foneImovel}" />
                                <div class="clear" />

                                <p:outputLabel id="obsOutputLabel" value="Obs:" styleClass="grid_3" />
                                <p:inputTextarea id="obsOutputText" styleClass="grid_20 ajustInput" readonly="true"
                                                 value="#{managerSearchRequirement.showReq.obs}" />

                            </p:panel>
                        </fieldset>


                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Anexos</h4></legend>
                            <ui:repeat  value="#{managerSearchRequirement.annexs}" var="a">

                                <h:outputLink  
                                    value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.description}"  target="_blank" >

                                    <div style="text-align: center; width: 20%;" class="grid_4">

                                        <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                        style="margin-left:1%; width: 100px;"
                                                        url="show/?annex=#{a.id}" />

                                        <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                 a.description.replace('.png','').replace(' ','_')}" 
                                                        style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                        <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                        style="margin-left:1%; width: 100px;" 
                                                        url="assets/images/pdf.jpeg" />

                                        <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                 a.description.replace('.pdf','').replace(' ','_')}" 
                                                        style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>
                                    </div>
                                    <f:param name="annex" value="#{a.id}"/>
                                </h:outputLink>

                            </ui:repeat>
                            <br/>
                        </fieldset>

                        <br/>
                        <div class="buttonAction">
                            <p:button href="searchreq.xhtml" value="Voltar"  icon="ui-icon-arrowreturnthick-1-w"/>
                        </div >
                    </div>
                </div>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
